package Day18;

import java.util.Arrays;
import java.util.Scanner;

public class Main6 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int M = scan.nextInt();
        int N = scan.nextInt();
        long[] points = new long[N];
        for (int i = 0; i < N; i++) {
            points[i] = scan.nextLong();
        }
        Arrays.sort(points);
        long ans = Long.MAX_VALUE;
        for (int i = 0; i <= N - M; i++) {
            int j = i + M - 1;
            long left = points[i];
            long right = points[j];
            if (right <= 0) {
                ans = Math.min(ans, -left);
            } else if (left >= 0) {
                ans = Math.min(ans, right);
            } else {
                long way1 = -2 * left + right;
                long way2 = -left + 2 * right;
                ans = Math.min(ans, Math.min(way1, way2));
            }
        }
        System.out.println(ans);
        scan.close();
    }
}